package com.LeeCode;

/**
 * 循环数组中相邻元素的最大差值
 */

public class Code3423 {
    public static void main(String[] args) {
        int[] nums = {1, 2, 4};
        System.out.println(new Code3423().maxAdjacentDistance(nums));
    }

    public int maxAdjacentDistance(int[] nums) {
        int n = nums.length;
        int ans = Math.abs(nums[n - 1] - nums[0]);
        for (int i = 1; i < n; i++) {
            ans = Math.max(ans, Math.abs(nums[i] - nums[i - 1]));
        }
        return ans;
    }
}
